import * as rbac from "f2e-middle-rbac/client/apis"
import { FetchAPI, ServerResult, User } from "f2e-middle-rbac/lib/interface";

export const api_common: {
    loginUser: FetchAPI<undefined, User>;
} = {
    loginUser: () => fetch("/admin/loginUser", { cache: 'no-cache' })
    .then(res => res.json())
    .then((_res) => {
        const res = _res as ServerResult<User>
        if (res.success && res.data) {
            res.data.permissions = new Set(res.data?.permissions ?? [])
        }
        return res
    })
}